package com.ruoyi.framework.dataScope.strategy;

import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.security.service.TokenService;
import com.ruoyi.project.system.domain.SysRole;
import com.ruoyi.project.system.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component("5")
public class PersonalDataAuth implements AbstractDataAuthHandler {
    @Autowired
    private TokenService tokenService;
    @Override
    public List<Long> getDeptIds(SysRole role, String scopeType) {
        // 用于存储部门id
        List<Long> deptIds = new ArrayList<>();
        SysUser user = tokenService.getLoginUser(ServletUtils.getRequest()).getUser();
        deptIds.add(user.getDeptId());
        return deptIds;
    }
}
